#{extends 'ApiDoc/base.html'/}

<script>
    $(function(){
        activeCate('.J-menu-cate-task');
    });
</script>

<link rel="stylesheet" type="text/css"
      href="#{href '/public/apidoc/layout/res_iframe.css'/}"/>

<link rel="stylesheet" href="#{href '/public/apidoc/view.css'/}">

<div class="page_doc">
    <div class="main_hd"><h2 id="title">任务日志</h2></div>
    <div class="main_bd">
        <div class="article_box">
            <div class="inner">

                <div class="gap"></div>

                #{list items: logs, as: 'l'}
                <table class="table">
                    <thead>
                    <tr>
                        <td>时间：
                            ${new Date(l.getLong('startTime')).fullDateTime()}
                            ~
                            #{if l.getLong('endTime') > 0}
                                ${new Date(l.getLong('endTime')).fullDateTime()}
                            #{/if}
                            #{else}
                                -
                            #{/else}
                        </td>
                        <td>时长：
                            #{if l.getLong('endTime') > 0}
                                ${(l.getLong('endTime') - l.getLong('startTime')).asDurationTime()}
                            #{/if}
                            #{else}
                                -
                            #{/else}
                        </td>
                        <td>当前进度：
                            #{if l.getInteger('progress') >= 100}
                                <span style="color: green">已完成</span>
                            #{/if}
                            #{else}
                                ${l.getInteger('progress')} %
                            #{/else}
                        </td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td colspan="3">
                            #{list items: l.getJSONArray('logs'), as: 'i'}
                                <div class="log-item">
                                    <span class="log-time">${new Date(i.getLong('time')).fullDateTime()}</span>
                                    <div class="log-content">
                                        #{if i.get('type') && i.get('type') != 'INFO'}
                                            <span class="log-type ${i.get('type')}">
                                                #{if i.get('type') == 'WARN'}[警告]#{/if}
                                                #{if i.get('type') == 'ERROR'}[错误]#{/if}
                                            </span>
                                        #{/if}

                                        <span>${i.get('content')}</span>

                                        #{if i.get('exception')}
                                        <pre>
                                            ${i.get('exception')}
                                        </pre>
                                        #{/if}
                                    </div>

                                </div>
                            #{/list}
                            #{if l.getLong('endTime') > 0}
                                <div class="log-item">
                                    <span class="log-time">${new Date(l.getLong('endTime')).fullDateTime()}</span>
                                    <div class="log-content">结束</div>
                                </div>
                            #{/if}
                        </td>
                    </tr>
                    </tbody>
                </table>

                <div class="gap"></div>
                #{/list}


            </div>
        </div>
    </div>

</div>